package com.dg11185.nearshop.net.response;

import java.util.ArrayList;
import java.util.List;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import android.util.Log;

/**
 * 
 * @author wanliang527
 * @date 2014-5-19
 */
public class GetCardListResponse {
    public final static String SUCCESS = "SUCCESS";// 查询成功
    public final static String FAILE = "FAILE";// 调用失败
    public final static String ILLEGAL_PAR = "ILLEGAL_PAR";// 参数异常
    public final static String MEM_NOTFOUND = "MEM_NOTFOUND";// 会员不存在
    public final static String MEM_ILLEGALPWD = "MEM_ILLEGALPWD";// 密码不正确
    public final static String EXCEPTION = "EXCEPTION";// WS调用失败
    public final static String ILLEGAL_SIGN = "ILLEGAL_SIGN";// 签名无效

    public String responseStr = "";
    public String status;
    public List<Card> cardList;

    public void parseJson(String response) throws JSONException {
        this.responseStr = response;
        JSONObject jsonObject = new JSONObject(response);
        status = jsonObject.getString("status");

        if (!jsonObject.isNull("cardList")) {
            JSONArray array = jsonObject.getJSONArray("cardList");
            cardList = new ArrayList<GetCardListResponse.Card>();
            for (int i = 0; i < array.length(); i++) {
                Card card = new Card();
                JSONObject object = array.getJSONObject(i);
                card.cardFaceNo = object.getString("cardFaceNo");
                card.cardDesc = object.getString("cardDesc");
                card.mobilePhone = object.getString("mobilePhone");
                card.createTime = object.getString("createTime");
                card.endTime = object.getString("endTime");
                cardList.add(card);
            }
        }

    }

    public static class Card {
        public String cardFaceNo;
        public String cardDesc;// 常惠卡类型（电子常惠卡（邮储赠卡）、普通二代卡、东莞通联名卡）
        public String mobilePhone;
        public String createTime;
        public String endTime;

    }

}
